program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  arr=array of integer;
var
  mass: array of arr;
  n, i, j: integer;
  fin, fout: textfile;
begin
  assignfile(fin, 'input.txt');
  reset(fin);
  assignfile(fout, 'output.txt');
  rewrite(fout);
  readln(fin, n);
  setlength(mass, n);
  for i:=0 to n-1 do
    setlength(mass[i], n);                                
  for i:=0 to n-1 do
    for j:=0 to n-1 do
      read(fin, mass[i,j]);
  for i:=0 to n-1 do
  begin
    for j:=0 to n-1 do
    begin
      if (mass[i, j]=1) and (mass[j, i]=1) then
      begin
        mass[i, j]:=5;
        writeln(fout, i+1, ' ', j+1);
      end;
    end;
  end;
  closefile(fin);
  closefile(fout);
end.
